import 'package:ladder_cash/app/key_mix.dart';
import 'package:ladder_cash/generated/l10n.dart';
import 'package:ladder_cash/app/com/http/http_request.dart';
import 'package:ladder_cash/app/com/http/Res.dart';
import 'package:liuxlcommon/util/toast_util.dart';

import '../../../library/src/logger.dart';

class InformationService {
  /// 图片上传并失败
  /// *spot: 图片来源:1拍照 2:相册选择
  ///height1: 10:人像,11身份证正面 12:身份证反面
  Future<Map?> uploadImgAndIde(String path, {spot, cardType,height1}) async {
    Res r = await HttpRequest().postfile(
        path,
        <String, dynamic>{
          'type'.hx: height1,
          'image_source'.hx: spot + 1,
        },
        parse: false,
        loadingText:S.current.uploading);
    if (r.success) {
      return r.data;
    } else {
      ToastUtils.toast(r.msg);
    }
    return null;
  }

  Future<bool> saveQuestionnaireSurvey(params) async {
    Res r = await HttpRequest().post('/v3/certify/save-credit-info'.hx, params,
        loadingText: S.current.loading, parse: false);
    return r.success;
  }

  Future<bool> saveUserInfo(params) async {
    Res r = await HttpRequest().post(
        '/v3/certify/save-personal-info'.hx, params,
        loadingText: S.current.loading, parse: false);
    return r.success;
  }

  Future<bool> saveJobInfo(params) async {
    Res r = await HttpRequest().post('/v3/certify/save-job-info'.hx, params,
        loadingText: S.current.loading, parse: false);
    return r.success;
  }

  Future<bool> saveContactInfo(params) async {
    Res r = await HttpRequest().post('/v3/certify/save-ext-info-new'.hx, params,
        loadingText: S.current.loading, parse: false);
    return r.success;
  }

  Future<bool> saveBankInfo(params) async {
    Res r = await HttpRequest().post('/v3/bind-card/bind-card-new'.hx, params,
        loadingText: S.current.loading, parse: false);
    return r.success;
  }
}
